import Immutable from 'immutable';

const defaultState = new Immutable.List();

export default function assetReducer(state = defaultState, action) {
  switch(action.type) {
    case 'CREATE_ASSET':
      return state.concat(action.text);
    case 'EDIT_ASSET':
      state = action.text
      return state;
    case 'DELETE_ASSET':
      state = _.remove(state, function(asset) {

        return action.id !== asset.id
      })
      return state;
    case 'LOAD_ASSETS':
      return action.data;
    case 'ERROR_ASSETS':
      return action.error.status;
    default:
      return state;
  }
}
